//
//  VipSpaceViewController.m
//  Yarhoo
//
//  Created by 杨春至 on 2018/5/24.
//  Copyright © 2018年 Yarhoo. All rights reserved.
//

#import "VipSpaceViewController.h"
#import "VipSpaceCollectionViewCell.h"
#import <SDCycleScrollView.h>

static NSString *const IDE = @"vip_collectionView_ide";

@interface VipSpaceViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,SDCycleScrollViewDelegate>

@property (nonatomic,strong) SDCycleScrollView *bannerView;

@property (nonatomic,strong) UICollectionView *vipCollectoionView;

@property (nonatomic,strong) NSMutableArray *dataSource;

@end

@implementation VipSpaceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configUI];
}
- (void)configUI{
    self.view.backgroundColor = KcolorLineGray;
    self.dataSource = @[@"",@"",@"",@"",@"",@"",@""].mutableCopy;
    [self.view addSubview:self.bannerView];
    [self.view addSubview:self.vipCollectoionView];
}
#pragma mark CollectionViewDelegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.dataSource.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    [collectionView registerClass:[VipSpaceCollectionViewCell class] forCellWithReuseIdentifier:IDE];
    VipSpaceCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:IDE forIndexPath:indexPath];
    
    return cell;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    CGFloat width = (SCREEN_WIDTH-1)*0.5;
    CGFloat height = 122.0/188.0*width;
    return CGSizeMake(width, height);
}
- (SDCycleScrollView *)bannerView{
    if (!_bannerView) {
        _bannerView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, self.view.width, 156.0/352*self.view.width) delegate:self placeholderImage:UIImageMake(@"banner_place")];
        _bannerView.localizationImageNamesGroup = @[UIImageMake(@"banner_place"),UIImageMake(@"banner_place"),UIImageMake(@"banner_place")];
    }
    return _bannerView;
}
- (UICollectionView *)vipCollectoionView{
    if (!_vipCollectoionView) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
        [layout setScrollDirection:UICollectionViewScrollDirectionVertical];
        layout.minimumLineSpacing = 0.5;
        layout.minimumInteritemSpacing = 0.5;
        _vipCollectoionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:layout];
        _vipCollectoionView.delegate = self;
        _vipCollectoionView.dataSource = self;
        _vipCollectoionView.backgroundColor = [UIColor whiteColor];
    }
    return _vipCollectoionView;
}
- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    [_vipCollectoionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_bannerView.mas_bottom).offset(1);
        make.left.right.bottom.equalTo(self.view);
    }];
}
@end
